/**
 * Bone.h
 * Coyright (c) 2009 Xiaofeng Gu. All Rights Reserved.
 * Author : Xiaofeng Gu
 *
 * Creation Data : 2009/06/11
 */

#pragma once

#include "Joint.h"
#include "IPersistence.h"

class CBone : public IPersistence
{
public:
	CBone();
	virtual ~CBone();

// operator
	CJoint&				operator[](unsigned int i);
	void				operator=(const CBone& bone);

	virtual bool		OnRead(CXMLParser* pParser);
	virtual bool		OnWrite(CXMLParser* pParser);

// method
public:
	bool				Rotate(CVec& Ref, double dAngle);
	bool				Rotate(CJoint& oJoint, CVec& Ref, double dAngle);
	bool				Screw(double dAngle);
	bool				Move(CVec& Ref);
	CVec				Direction();

// property
public:
	CVec&				GetNormal()
	{ return m_oNormal; }

private:
	CJoint				m_FixedJoint, m_MovingJoint;
	CVec				m_oNormal;
};

inline CJoint& CBone::operator[](unsigned int i)
{
	return *(&m_FixedJoint + i);
}